<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <ui:composition>
        <style type="text/css">
            .gridStyle{
                margin:10px 10px 10px 0px;
            }
            .top{
                vertical-align: top;
            }
        </style>

        <h:form id="dataInputInformation">
            <rich:panel id="typeChoicePanel" style="height:45px;">
                选择存货类型：<h:inputText value="#{inventBean.inventType.name}"
                                    readonly="true"
                                    ondblclick="#{rich:component('inventTypePanel')}.show();"/>
                <a4j:commandButton value="查询"
                                   action="#{inventBean.queryli}"
                                   disabled="#{inventBean.inventType eq null}"
                                   execute="@this"
                                   render="ipanel"
                                   immediate="true"
                                   onclick="this.disabled='true';"/>
            </rich:panel>
            
            <rich:panel header="存货档案" id="ipanel" styleClass="content-hight">
                <rich:messages/>
                <rich:toolbar id="tolbar1">
                    <rich:toolbarGroup>
                        <a4j:commandButton value="新增" execute="@this"
                                           render="tolbar1,editGrid"
                                           action="#{inventBean.add}"
                                           disabled="#{inventBean.inventType eq null}">
                        </a4j:commandButton>

                        <a4j:commandButton value="修改" execute="@this" render="ipanel"
                                           action="#{inventBean.update}"
                                           disabled="#{inventBean.addOrUpdate or
                                                       empty inventBean.dataInput}">
                        </a4j:commandButton>

                        <a4j:commandButton value="保存" render="ipanel"
                                           action="#{inventBean.save}"
                                           disabled="#{!inventBean.editStatus}">
                        </a4j:commandButton>

                        <a4j:commandButton value="删除" execute="@this" render="ipanel"
                                           action="#{inventBean.delete}"
                                           disabled="#{inventBean.addOrUpdate or
                                                       empty inventBean.dataInput}">
                        </a4j:commandButton>

                        <a4j:commandButton value="取消" execute="@this" render="ipanel"
                                           action="#{inventBean.cancel}"/>
                    </rich:toolbarGroup>
                </rich:toolbar>

                <h:panelGrid columns="4" id="editGrid">                 
                    <h:outputText value="编码："/>
                    <h:inputText disabled="#{true}"
                                 value="#{inventBean.dataInput.id}"/>

                    <h:outputText value="名称："/>
                    <h:inputText disabled="#{!inventBean.editStatus}" id="name"
                                 value="#{inventBean.dataInput.name}" 
                                 required="true" requiredMessage="名称不能为空！"/>

                    <h:outputText value="简称："/>                    
                    <h:inputText disabled="#{!inventBean.editStatus}" id="simpleName"
                                 value="#{inventBean.dataInput.simplename}" 
                                 required="true" requiredMessage="简称不能为空！"/>

                    <h:outputText value="计量单位："/>
                    <h:inputText disabled="#{!inventBean.editStatus}" id="id"
                                 value="#{inventBean.dataInput.measure}" 
                                 required="true" requiredMessage="计量单位不能为空！"/>

                    <h:outputText value="计量单位(英文)："/>
                    <h:inputText disabled="#{!inventBean.editStatus}"
                                 value="#{inventBean.dataInput.measureen}" 
                                 required="true" requiredMessage="计量单位(英文)不能为空！"/>

                    <h:outputText value="规格："/>
                    <h:inputText disabled="#{!inventBean.editStatus}"
                                 id="account"
                                 value="#{inventBean.dataInput.model}" 
                                 required="true" requiredMessage="规格不能为空！"/>

                    <h:outputText value="商品描述："/>
                    <h:inputText disabled="#{!inventBean.editStatus}"
                                 id="bankAccount"
                                 value="#{inventBean.dataInput.descri}"
                                 required="true" requiredMessage="商品描述不能为空！"/>

                </h:panelGrid>

                <h:panelGroup id="tableGroup">
                    <rich:dataScroller for="dataInputinfo" execute="@this" render="tableGroup"/>
                    <div style="max-width: 750px;overflow:auto;">
                        <rich:dataTable value="#{inventBean.dataList}"
                                        var="dataInput"
                                        style="width:100%;margin-bottom: 5px;"
                                        rows="10"
                                        rowKeyVar="rowKey"
                                        id="dataInputinfo"
                                        styleClass="tableStyle"
                                        noDataLabel="无数据！">

                            <f:facet name="header">
                                <h:outputText value="存货档案" />
                            </f:facet>

                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="编码"/>
                                    </h:panelGroup>
                                </f:facet>
                                <a4j:commandLink value="#{dataInput.id}"
                                                 action="#{inventBean.selected(rowKey)}"
                                                 execute="@this"
                                                 render="tolbar1,editGrid"/>
                            </rich:column>

                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="名称"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText  value="#{dataInput.name}" />
                            </rich:column>

                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="简称"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText  value="#{dataInput.simplename}"/>
                            </rich:column>

                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="计量单位"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{dataInput.measure}"/>
                            </rich:column>

                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="规格"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{dataInput.model}"/>
                            </rich:column>

                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="商品描述"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{dataInput.descri}"/>
                            </rich:column>

                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="存货类型"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{dataInput.type.name}"/>
                            </rich:column>

                        </rich:dataTable>
                    </div>
                </h:panelGroup>
            </rich:panel>
        </h:form>

        <rich:popupPanel id="inventTypePanel" autosized="true">
            <f:facet name="header">存货类型</f:facet>
            <f:facet name="controls">
                <h:outputLink value="#"
                              onclick="#{rich:component('inventTypePanel')}.hide();
                                            return false;">
                    关闭
                </h:outputLink>
            </f:facet>
            <h:form>
                <rich:panel>
                    <div style="min-height: 300px;max-height:400px;min-width:350px;overflow: auto;">
                        <rich:tree
                            value="#{inventTypeBean.rootNode}"
                            var="idept"
                            selectionType="ajax"
                            toggleType="client"
                            selectionChangeListener="#{inventBean.treeSelected}"
                            style="width:300px"
                            render="typeChoicePanel,ipanel">
                            <rich:treeNode ondblclick="#{rich:component('inventTypePanel')}.hide();">
                                <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                            </rich:treeNode>
                        </rich:tree>
                    </div>
                </rich:panel>
            </h:form>
        </rich:popupPanel>
    </ui:composition>
</html>
